﻿
function AccountViewModel() {
    var self = this;

    self.UserName = ko.observable();

    self.ResetPassword = function () {
       
        var myData = ko.toJSON(self);
        
        jQuery.ajax({
            url: "./Account/PasswordResetRequest/",
            type: 'post',
            data: myData,
            contentType: 'application/json',
            success: function (result) {
                $('#success-dis').text('Password reset link has been sent to your email');
                $('#register-error').css({ 'display': 'none' });
                $('#success-msg').css({ 'display': 'block' });
                $(document).scrollTop(0);
            },
            error: function (xhr, ajaxOptions, thrownError) {
                $('#success-msg').css({ 'display': 'none' });
                $('#register-error').css({ 'display': 'block' });
                $('#error-dis').text(thrownError);
                
                $(document).scrollTop(0);
            }
        });
    };
}

function AccountNewPasswordViewModel() {
    var self = this;

    self.NewPassword = ko.observable();
    //self.ConfPassword = ko.observable();
    
    self.ResetPasswordAction = function () {
        //alert('Reset password action script');

        var myData = ko.toJSON(self);

        jQuery.ajax({
            url: "./Account/PasswordResetAction/",
            type: "post",
            data: myData,
            contentType: "application/json",
            success: function (result) {
                $("#Main").html(result);
            }
        });
    };
}